<?php
if(!class_exists('XBasicTable', false)){
	require(XFRAMEWORK_DIR.'/module/orm/table/XBasicTable.php');
}
class XShardTable extends XBasicTable{
	protected $shardId = null;
	
	public function __construct(XTable $table){
		$this->setName($table->name());
		$this->setColumns($table->columns());
		$this->setPK($table->PK());
	}

	/**
	 * @return XShardTable
	 */	
	public function setShardId($shardId){
		$this->shardId = $shardId;
		return $this;
	}
	
	public function shardId(){
		return $this->shardId;
	}

	public function validate(){
		parent::validate();
		if(!$this->shardId){
			throw new XORMException("table {$this->name} doesn't have an shard id.");
		}
	}
}
?>